from sqlalchemy import Column, Integer, String, Text, DateTime, func, ForeignKey, Boolean
from sqlalchemy.orm import relationship

from database import Base  # 你已有的 declarative_base 实例


class TestVersion(Base):
    __tablename__ = "test_version"
    __table_args__ = {'comment': '测试版本表'}

    id = Column(Integer, primary_key=True, index=True, comment="版本ID")
    project_id = Column(Integer, ForeignKey("test_projects.id"), nullable=False, comment="关联项目ID")
    version_name = Column(String(50), nullable=False, comment="版本名称")

    project = relationship("TestProject", back_populates="versions")
    test_plans = relationship("TestPlan", back_populates="version", cascade="all, delete-orphan")
